//
//  main.m
//  HomeWork6-1
//
//  Created by dllo on 15/10/30.
//  Copyright (c) 2015年 dllo. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "Contact.h"
#import "ContactManager.h"

int main(int argc, const char * argv[]) {

    Contact *per1 = [[Contact alloc] initWithName:@"WN" sex:@"girl" phone:@"1233333" age:80];
    Contact *per2 = [[Contact alloc] initWithName:@"WBN" sex:@"man" phone:@"123333444" age:24];
    Contact *per3 = [[Contact alloc] initWithName:@"ZY" sex:@"girl" phone:@"1233333555" age:18];
    Contact *per4 = [[Contact alloc] initWithName:@"WDD" sex:@"man" phone:@"123333666" age:30];
    
    
    // 3, 可以添加联系人对象，如果姓名或电话号码为空，添加失败。添加联系人到匹配的分组。
    ContactManager *contactList = [[ContactManager alloc] init];
    [contactList addContact:per1];
    [contactList addContact:per2];
    [contactList addContact:per3];
    [contactList addContact:per4];
    
    
    
    // 4.获取某个分组名称下所有联系人，并且按照姓名升序排列。
//    NSMutableArray *arr = [contactList getSortedNameOfKey:@"W"];
//    
//    for (Contact *contact in arr) {
//        NSLog(@"%@", contact.name);
//    }
    
    
    
    // 7,根据姓名删除某个联系人。
    
//    [contactList deleteContactWithName:@"WN"];
    
    // 8,删除某个分组的全部联系人.
    
//    [contactList deleteGroupWithKey:@"W"];
    
    //  5,从通讯录中根据电话号码搜索联系人。
//    NSMutableArray *arr = [contactList searchContactWithPhone:@"123333444"];
//    
//    for (Contact *contact in arr) {
//        NSLog(@"%@ %@ %@ %ld", contact.name, contact.sex, contact.phone, contact.age);
//    }
    
    // 6,获取所有女性的联系人，并且按照年龄的降序排列。
    NSMutableArray *arr = [contactList getAllGirlsSortedOfAge];
        for (Contact *contact in arr) {
            NSLog(@"%@ %@ %@ %ld", contact.name, contact.sex, contact.phone, contact.age);
        }
    
    
//    [contactList allContactInfo];
    
    
    
    
    
    
    return 0;
}
